<?php
session_start(); /*
  if ($_SESSION["autentificado"] != "1") {
  header("location: ../?AccessNotAuthorized=:(");
  } */
?>
<!DOCTYPE html>
<!--[if lt IE 7 ]> <html lang="en" class="no-js ie6 lt8"> <![endif]-->
<!--[if IE 7 ]>    <html lang="en" class="no-js ie7 lt8"> <![endif]-->
<!--[if IE 8 ]>    <html lang="en" class="no-js ie8 lt8"> <![endif]-->
<!--[if IE 9 ]>    <html lang="en" class="no-js ie9"> <![endif]-->
<!--[if (gt IE 9)|!(IE)]><!--> 

<html lang="es" class="no-js"> <!--<![endif]-->
    <head>
        <meta charset="UTF-8" />
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
        <title>Acceso | Guía Pilar</title>
        <meta name="viewport" content="width=device-width, initial-scale=1.0"> 
        <meta name="description" content="Sistema de ABM" />
        <meta name="keywords" content="" />
        <meta name="author" content="Evert Code" />

        <!--<link rel="shortcut icon" href="image/favicon.ico">--> 
        <link href="script/bootstrap/css/bootstrap.css" rel="stylesheet">
        <link href="css/signin.css" rel="stylesheet">
        <link rel="stylesheet" href="script/jquery/validationengine/validationEngine.jquery.css" type="text/css" />

    </head>
    <body>
        <div id="wrap">
            <div class="container">
                <div class="row">
                    <div class="col-lg-12 text-center">
                     <!--  <img class="img-responsive img-thumbnail" alt="ABM" src="image/logo.jpg" /> -->
                    </div>
                </div>
                <form class="form-signin" role="form" autocomplete="on">
                    <h2 class="form-signin-heading text-center">Acceso al Sistema Guía Pilar</h2>
                    <input type="text" class="form-control validate[required]" required="required" type="text" id="username" name="username" placeholder="Usuario" required autofocus>
                    <h2 class="form-signin-heading text-center"> </h2>
					<input type="password" id="password" name="password" class="form-control validate[required]" placeholder="Contraseña" required="required">
                    <button id="btn" class="btn btn-lg btn-danger btn-block" type="submit">Iniciar Sesión</button>
                </form>
            </div>
        </div>

        <script type="text/javascript" src="script/jquery/jquery.min.js"></script>
        <script src="script/bootstrap/js/bootstrap.min.js"></script>
        <script type="text/javascript" src="script/jquery/jquery-ui.min.js"></script>
        <script type="text/javascript" src="script/jquery/jquery.blockUI.js" charset="utf-8"></script>
        <script type="text/javascript" src="script/jquery/validationengine/jquery.validationEngine-es.js"></script>
        <script type="text/javascript" src="script/jquery/validationengine/jquery.validationEngine.js" charset="utf-8"></script>
        <script type="text/javascript">
            isotechERRCSS = {
                width: '350px',
                heigh: '200',
                top: '10px',
                left: '',
                right: '10px',
                border: 'none',
                padding: '5px',
                opacity: 0.6,
                cursor: 'default',
                color: '#fff',
                backgroundColor: '#000',
                '-webkit-border-radius': '10px',
                '-moz-border-radius': '10px',
                'border-radius': '10px'
                , backgroundImage: 'url(script/jquery/validationengine/check49.png)'
                , backgroundRepeat: 'no-repeat'
                , backgroundSize: '48px 48px'
                , backgroundPosition: '27px 21px'
            };

            $.isotechERRUI = function(title, message, timeout, onClose) {
                var $m = $('<div class="growlUI"></div>');
                if (title)
                    $m.append('<h1>' + title + '</h1>');
                if (message)
                    $m.append('<span>' + message + '</span>');
                if (timeout === undefined)
                    timeout = 5000;
                $.blockUI({
                    message: $m,
                    fadeIn: 150,
                    fadeOut: 150,
                    centerY: false,
                    timeout: timeout,
                    showOverlay: false,
                    onUnblock: onClose,
                    css: isotechERRCSS
                });
            };

            $.login = function() {
                $.ajax({
                    syncn: 'false',
                    type: 'post',
                    url: 'opt/acceso.php',
                    data: {
                        login: '-',
                        usuario: $('#username').val(),
                        password: $('#password').val()
                    },
                    success: function(data) {
                        var json = eval('(' + data + ')');
                        if (json.success === 1) {
                            location.href = 'app/';
                        } else {
                            $.isotechERRUI('Error!', 'Usuario o password incorrectos intente nuevamente');
                        }
                    }
                });
            };

            $(document).on('ready', function() {
                $('#username').focus();
                var $btn = $('#btn').on('click', function() {
                    if ($('#acceso').validationEngine('validate'))
                        $.login();
                    return false;
                });
<?php
if (isset($_GET['AccessNotAuthorized']))
    echo "$.isotechERRUI('Error!', 'No tienes privilegios para acceder a esa pagina.');"
    ?>
            });
        </script>
    </body>
</html>